package com.chauncy.DMS.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.chauncy.DMS.bean.StuDormInfoBean;
import com.chauncy.DMS.dao.UserDaoImplement;

public class DormInfoServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
		UserDaoImplement udi = new UserDaoImplement();
		String dormitoryNumber = request.getParameter("dormitoryNumber");
		String dormNumber = request.getParameter("dormNumber");
		
		
		
		List<StuDormInfoBean> list = new ArrayList<StuDormInfoBean>();
		try {
			list = udi.selectRoommate(dormitoryNumber,dormNumber);
			if(list.size() > 0){
				HttpSession session = request.getSession();
				session.setAttribute("roommateInfoList", list);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("./html/dorm_info.jsp");
		
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
